package com.yayohos.locationmanager;

import com.yayohos.locationmanager.base.LocationBaseFraction;
import com.yayohos.locationmanager.fractions.SimpleFraction;
import com.yayohos.locationmanager.helper.LogUtils;

import ohos.aafwk.ability.fraction.FractionAbility;
import ohos.aafwk.content.Intent;

/**
 * 在Fraction中定位
 */
public class SampleFractionAbility extends FractionAbility {
    private LocationBaseFraction.PermissionCallBack permissionCallBack;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        LogUtils.logI("onStart++");
        setUIContent(ResourceTable.Layout_ability_simple_fraction);
        getFractionManager().startFractionScheduler().add(
                ResourceTable.Id_stackLayout, new SimpleFraction(), "sampleFraction").submit();
    }

    public void setPermissionCallBack(LocationBaseFraction.PermissionCallBack permissionCallBack) {
        this.permissionCallBack = permissionCallBack;
    }


    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
        permissionCallBack.onRequestPermissionsFromUserResult(requestCode, permissions, grantResults);
    }
}
